import './App.css'
import React from 'react'
import Home from './page/Home'
import Login from './page/Login'
import Register from './page/Register'
import Detail from './page/Detail'
import Error from './page/Error'
// 引入react router
// 1 BrowserRouter  浏览器版本的 路由  是因为react reactnative   appRouter
// 2 Route 路由出口
import { BrowserRouter, Route, Switch } from 'react-router-dom'
class App extends React.Component {
  constructor(props) {
    super(props)
    this.state = {
      flag: 1,
      username: ''
    }
    var username = sessionStorage.getItem('username')
    this.state.username = username

  }


  a = (e) => {


  }



  render() {
    return (

      <div>

        {
          this.state.username ? (
            <BrowserRouter>
              <Switch>
                <Route exact path='/' component={Home}></Route>
                <Route path='/login' component={Login}></Route>
                <Route path='/register' component={Register}></Route>
                <Route path='/detail/:travelid' component={Detail}></Route>
                {/* <Route path='/detail' component={Detail}></Route> */}
                <Route component={Error}></Route>
              </Switch>


            </BrowserRouter>
          ) : (
            <BrowserRouter>
              <Switch>
                <Route exact path='/' component={Home}></Route>
                <Route path='/login' component={Login}></Route>
                <Route path='/register' component={Register}></Route>
                {/* <Route path='/detail/:travelid' component={Detail}></Route> */}
                {/* <Route path='/detail' component={Detail}></Route> */}
                <Route  component={Login}></Route>
              </Switch>


            </BrowserRouter>

          )
        }



      </div>

    )
  }



}



export default App
